package com.example.entity.message.impl;

import com.example.entity.body.impl.InitBody;
import com.example.entity.header.Header;
import com.example.entity.message.Message;

import io.netty.buffer.ByteBuf;

public class InitMessage extends Message {

	public InitMessage() {
		Header header = new Header();
		InitBody body = new InitBody();
		
		setHeader(header);
		setBody(body);

	}

	public InitMessage(ByteBuf frame) {
		Header header = new Header();
		InitBody body = new InitBody();

		header.setContextLength( frame.readableBytes());

		body.setType(frame.readChar());
		body.setCostModelID(frame.readLong());
		body.setEquipmentID(frame.readLong());
		body.setElectricPortNum(frame.readByte());
		body.setElectricModel(frame.readByte());
		body.setAddr(frame.readChar());
		
		setHeader(header);
		setBody(body);
	}


}
